/**
 * Definition for singly-linked list.
 * type ListNode struct {
 *     Val int
 *     Next *ListNode
 * }
 */
func reverseList(head *ListNode) *ListNode {
	b := head
	var arr []int = make([]int, 0)
	for {
		if b == nil {
			break
		} else {
			arr = append(arr, b.Val)
			b = b.Next
		}
	}
	b = head
	for i := len(arr) - 1; i >= 0; i-- {
		b.Val = arr[i]
		b = b.Next
	}
	return head
}